# Contributor: Christoph Reiter <reiter.christoph@gmail.com>

_realname=attrs
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=20.3.0
pkgrel=1
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgdesc='Attributes without boilerplate (mingw-w64)'
url='https://attrs.readthedocs.org/'
license=('MIT')
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${CARCH}| true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
